package vn.edu.uit.chemistry;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.TabHost;

public class MainActivity extends TabActivity {

	TabHost tabHost = null;
	Button btnBaiGiang;
	Button btnKiemTra;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		tabHost = getTabHost();
		setUI();
		setTabHost();
	}

	private void setTabHost() {
		tabHost.addTab(tabHost.newTabSpec("BaiGiang").setIndicator("Bài giảng")
				.setContent(new Intent(MainActivity.this, test1.class)));
		tabHost.addTab(tabHost.newTabSpec("KiemTra").setIndicator("Kiểm tra")
				.setContent(new Intent(MainActivity.this, test2.class)));
		tabHost.setCurrentTab(0);
	}

	private void setUI() {


		btnBaiGiang = (Button) findViewById(R.id.btnBaiGiang);
		btnBaiGiang.setOnTouchListener(new OnTouchListener() {

			public boolean onTouch(View v, MotionEvent event) {
				getTabHost().setCurrentTab(0);
				return false;
			}
		});

		btnKiemTra = (Button) findViewById(R.id.btnKiemTra);
		btnKiemTra.setOnTouchListener(new OnTouchListener() {

			public boolean onTouch(View v, MotionEvent event) {
				getTabHost().setCurrentTab(1);
				return false;
			}
		});
	}
}
